﻿
#ifndef __AmapViewImpl_H__
#define __AmapViewImpl_H__

#include "CrossApp.h"
#include "AmapView.h"

USING_NS_CC;

class AmapViewImpl : public CAObject
{
    
public:

	AmapViewImpl(AmapView *mapView);

	virtual ~AmapViewImpl();

	void setMapCenter(double lat, double lng);

	void startLocation();

	void setMapZoomLevel(double level);

	void addMarker(AmapMarker* marker);

	void deleteMarker(AmapMarker* marker);

	std::map<string, AmapMarker*>& getAllMarkers();

	void clearMarkers();

	void setAmapRouteViewType(double slat, double slng, double elat, double elng, AmapRouteViewType type);

	void searchRoute();

	void setBusRouteCity(const string& city, const string& cityd = "");

	void showBusRouteView(const int busTag);

	void getBusRouteStep(int bustag);

	void setVisible(bool visible);
    
#if (CC_TARGET_PLATFORM != CC_PLATFORM_IOS)

	static void onAmapLoaded(const int viewTag);

	static void onAmapClicked(const int viewTag, double lat, double lng);

	static void onAmapLocationEnd(const int viewTag, int code, double lat, double lng, const string& formatAddr, const string& province, const string& city, const string& district, const string& street, const string& number, const string& poi, const string& adcode);
    
    static void onAmapMarkerDragStart(const int viewTag, const string& markertag, double lat, double lng);
    
    static void onAmapMarkerDrag(const int viewTag, const string& markertag, double lat, double lng);
    
    static void onAmapMarkerDragEnd(const int viewTag, const string& markertag, double lat, double lng);
    
    static void onAmapMarkerClick(const int viewTag, const string& markertag);
    
    static void onAmapMarkerInfoWindowClick(const int viewTag, const string& markertag);

	static void onDriveRouteSearched(const int viewTag, int code, DriveRouteData data);

	static void onWalkRouteSearched(const int viewTag, int code, WalkRouteData data);

	static void onBusRouteSearched(const int viewTag, int code, std::vector<BusRouteData> data);

	static void onBusRouteSteps(const int viewTag, int code, const int bustag, std::vector<BusRouteStep> data);
    
#else
    
    static void onAmapClicked(void* amapwrapper, double lat, double lng);

	static void onAmapLocationEnd(void* amapwrapper, int code, double lat, double lng, const string& formatAddr, const string& province, const string& city, const string& district, const string& street, const string& number, const string& poi, const string& adcode);
    
    static void onAmapMarkerDragStart(void* amapwrapper, const string& markertag, double lat, double lng);
    
    static void onAmapMarkerDrag(void* amapwrapper, const string& markertag, double lat, double lng);
    
    static void onAmapMarkerDragEnd(void* amapwrapper, const string& markertag, double lat, double lng);
    
    static void onAmapMarkerClick(void* amapwrapper, const string& markertag);
    
    static void onAmapMarkerInfoWindowClick(void* amapwrapper, const string& markertag);

	static void onDriveRouteSearched(void* amapwrapper, int code, DriveRouteData data);

	static void onWalkRouteSearched(void* amapwrapper, int code, WalkRouteData data);

	static void onBusRouteSearched(void* amapwrapper, int code, std::vector<BusRouteData> data);

	static void onBusRouteSteps(void* amapwrapper, int code, const int bustag, std::vector<BusRouteStep> data);
    
#endif

	void update(float dt);

private:

	int _viewTag;

	AmapView* m_pAmapView;

	void* m_pAmapWrapper;

	std::map<string, AmapMarker*> s_AmapMarkers;
};

#endif
